package com.gitee.ywj1352.zk;

import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.recipes.locks.InterProcessMutex;

/**
 * @author wenjie.yang on 2019/6/19.
 */
public class CuratorDemo {

    // 真正的使用的 Curator 来获取锁  如果要
    public static void main(String[] args) throws Exception {
        CuratorFramework curatorFramework = CuratorFrameworkFactory.builder().build();

        InterProcessMutex interProcessMutex = new InterProcessMutex(curatorFramework,"/locks");
        //获取锁
        interProcessMutex.acquire();

        interProcessMutex.release();
    }

}
